<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use App\models\BaseConfig;

class ConfigController extends CommonController{
	
    public function __construct(Request $request){
        parent::__construct($request); 
    }
    
    
    /**
     * 管理员列表
     */
    function index(){
    	$result = DB::table('base_config')->where('type','!=' ,'hidden')->get();
    	return view('config.index',['data'=>$result]);
    }
    
    /**
     * 添加
     */
    function edit(){
    	
    	$param = $this->request->except('_token');
    	
    	$where = [];
    	$row   = [];
    	foreach($param as $key =>$value){
    		$where = array('item_key'=>$key);
    		$row   = array('item_value'=>$value);
    		$result = DB::table('base_config')->where($where)->update($row);
    	}
    	
    	return response()->json(['code'=>1,'msg'=>'更新成功','data'=>$result]);
    }
    
}
